<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数的扩展</title>
</head>
<body>
    <script>
        function test(name = 'huli', {age = 12, gender = 'm'}) {
            console.log(name + ' is ' + age);
        }

        test('yy', {});
        // test('hh'); // 报错，age 不存在

        function test2(name = 'huli', {age = 14, gender = 'girl'} = {}){
            console.log(name + ' is a' + age + gender);
            console.log(arguments);
        }

        // undefined 可以触发默认值，null 不可以

        // length 的属性含义是该函数与其传入的参数个数，指定默认值后，预期传入的参数就不包括该参数和之后的参数了
        // 
        console.log(test2.length);

        // 箭头函数
        function rowFun() {
            setTimeout(() => {
                console.log('id:', this.id);
            }, 100);
        }

        function traditionalFun() {
            setTimeout(function() {
                console.log('id+', this.id);
            })
        }

        var id = 201;
        rowFun();
        traditionalFun();
        console.log('id-', id);
        console.log(this);


    </script>
</body>
</html>